//
//  GameConfirmController.m
//  ELife
//
//  Created by xiaozhi on 11-5-20.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "GameConfirmController.h"
#import "GameResultController.h"

@implementation GameConfirmController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.view.backgroundColor 
        = [[UIColor alloc]initWithPatternImage:[UIImage imageNamed:@"bg.png"]];
    UIView *labelContainer = [self.view viewWithTag:TAG_LABEL_CONTAINER_VIEW];
    UIView *textView = [self.view viewWithTag:TAG_TEXTVIEW];
    
    labelContainer.layer.cornerRadius = 8;
    labelContainer.layer.masksToBounds = YES;
    textView.layer.cornerRadius = 8;
    labelContainer.layer.masksToBounds = YES;
    
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void) confirm:(id)sender
{
#warning for test
    UIButton *clickButton = (UIButton *)sender;
    CHARGE_RESULT result;
    switch (clickButton.tag) {
        case TAG_BUTTON_LEFT:
            result = SUCCESSFUL;
            break;
        case TAG_BUTTON_RIGHT:
            result = FAIL;
            break;
        default:
            break;
    }
    
    GameResultController *nextController = [[GameResultController alloc] initWithResult:result];
    
    [self.navigationController pushViewController:nextController animated:YES];
    [nextController release];
    
}

@end
